import pymysql

#创建数据库连接
conn = pymysql.connect(host="192.168.40.143", user="root", password="123456", database="litemall", port=3306)

#创建游标cursor
cursor = conn.cursor()

#执行SQL
cursor.execute("select id, name from litemall_goods")

#取全部数据，打印
print(cursor.fetchall())

#关闭游标
cursor.close()

#关闭连接
conn.close()
